package com.neuedu.ylbx.controller;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.neuedu.ylbx.pojo.HospitalReimbursement;
import com.neuedu.ylbx.service.ReimbursementService;
import com.neuedu.ylbx.utils.ResultVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/reimbursement")
@Tag(name = "报销管理")
@CrossOrigin
public class ReimbursementController {    //报销管理
    @Autowired
    private ReimbursementService reimbursementService;

    @GetMapping("/reimbursementpage")
    @Operation(summary = "获取报销比例列表")
    public ResultVo listReimbursementPage() {
        return ResultVo.ok(reimbursementService.list());
    }
    @PostMapping("/addreimbursement")
    @Operation(summary = "添加报销")
    public ResultVo addReimbursement(HospitalReimbursement hospitalReimbursement) {
        reimbursementService.save(hospitalReimbursement);
        return ResultVo.ok("成功");
    }
    @PutMapping("/updatereimbursement")
    @Operation(summary = "修改报销信息")
    public ResultVo updateReimbursement(HospitalReimbursement hospitalReimbursement) {
        UpdateWrapper<HospitalReimbursement> updateWrapper = new UpdateWrapper<HospitalReimbursement>();
        updateWrapper.eq("id",hospitalReimbursement.getId());
        reimbursementService.update(hospitalReimbursement,updateWrapper);
        return ResultVo.ok("修改成功");
    }
    @DeleteMapping("/deletereimbursement")
    @Operation(summary = "删除报销")
    public ResultVo deleteReimbursement(Integer id) {
        reimbursementService.removeById(id);
        return ResultVo.ok("删除成功");
    }
    @DeleteMapping("/deletereimbursements")
    @Operation(summary = "批量删除报销")
    public ResultVo deleteReimbursements(@RequestBody List<Long> Ids) {
        reimbursementService.removeByIds(Ids);  // MyBatis-Plus 批量删除方法
        return ResultVo.ok("批量删除成功");
    }
}
